home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- CLASS: MiscGaugeView
-
- See the interface file for more information on this class.
-
- This object is included in the MiscKit by permission from the author
- and its use is governed by the MiscKit license, found in the file
- "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- for a list of all applicable permissions and restrictions.
- ****************************************************************************/
-
- #import <appkit/appkit.h>
- #import "MiscGaugeCell.h"
- #import "MiscGaugeView.h"
-
- // The cell our Control will display.
- id myCellClass;
-
-
- @implementation MiscGaugeView
-
- + initialize
- {
- if (self == [MiscGaugeView class])
- // By default use the MiscGaugeCell cell.
- myCellClass = [MiscGaugeCell class];
- return self;
- }
-
-
- + setCellClass: aClass
- {
- myCellClass = aClass;
- return self;
- }
-
-
- - initFrame: (const NXRect *)frameRect
- {
- // Basic initFrame method which just calls the more complicated
- // initFrame:min:max... method with some generally good default values.
- [self initFrame:frameRect min:0.0 max:100.0
- startAngle:215.0 range:250.0 tickInterval:10];
- return self;
- }
-
-
- - initFrame:(const NXRect *)frameRect min:(float)min max:(float)max
- startAngle:(float)start range:(float)range tickInterval:(int)interval
- {
- if ([super initFrame: frameRect] == nil)
- return nil;
-
- // Set ourselves to use our gaugecell. Free the old cell.
- [ [self setCell: [ [myCellClass alloc] init] ] free];
- // [self setOpaque: NO];
-
- [self setStartAngle: start];
- [self setAngleRange: range];
- [self setTickInterval: interval];
- [self setMinValue: min];
- [self setMaxValue: max];
- [self setFloatValue: min];
- [self setTitleFont: [Font newFont: "Helvetica" size: 10
- matrix: NX_IDENTITYMATRIX] ];
- return self;
- }
-
-
- - (float)maxValue { return [ (MiscGaugeCell *)[self cell] maxValue]; }
- - (float)minValue { return [ (MiscGaugeCell *)[self cell] minValue]; }
-
-
- - setMaxValue: (float)max
- {
- // Don't redraw if the new max is the same as the old.
- if (max != [ (MiscGaugeCell *)[self cell] maxValue])
- {
- [ (MiscGaugeCell *)[self cell] setMaxValue: max];
- [self update];
- }
- return self;
- }
-
-
- - setMinValue: (float)min
- {
- // Don't redraw if the new min is the same as the old.
- if (min != [ (MiscGaugeCell *)[self cell] maxValue])
- {
- [ (MiscGaugeCell *)[self cell] setMinValue: min];
- [self update];
- }
- return self;
- }
-
-
- - (float)startAngle { return [ [self cell] startAngle]; }
- - (float)angleRange { return [ [self cell] angleRange]; }
- - (int)tickInterval { return [ [self cell] tickInterval]; }
- - (float)tickRatio { return [ [self cell] tickRatio]; }
- - (float)handRatio { return [ [self cell] handRatio]; }
-
-
- - setStartAngle:(float)newValue
- {
- if (newValue != [ [self cell] startAngle])
- {
- [ [self cell] setStartAngle: newValue];
- [self update];
- }
- return self;
- }
-
-
- - setAngleRange:(float)newValue
- {
- if (newValue != [ [self cell] angleRange])
- {
- [ [self cell] setAngleRange: newValue];
- [self update];
- }
- return self;
- }
-
-
- - setTickInterval:(int)newValue
- {
- if (newValue != [ [self cell] tickInterval])
- {
- [ [self cell] setTickInterval: newValue];
- [self update];
- }
- return self;
- }
-
-
- - setTickRatio: (float)newRatio
- {
- if (newRatio != [ [self cell] tickRatio])
- {
- [ [self cell] setTickRatio: newRatio];
- [self update];
- }
- return self;
- }
-
-
- - setHandRatio: (float)newRatio
- {
- [ [self cell] setHandRatio: newRatio];
- [self updateCellInside: [self cell] ];
- return self;
- }
-
-
- //- (NXColor)backgroundColor { return [ [self cell] backgroundColor]; }
- - (NXColor)gaugeColor { return [ [self cell] gaugeColor]; }
- - (NXColor)textColor { return [ [self cell] textColor]; }
-
- /*
- - setBackgroundColor: (NXColor)color
- {
- if (NXEqualColor (color, [self backgroundColor]) == NO)
- {
- [ [self cell] setBackgroundColor: color];
- [self update];
- }
- return self;
- }
- */
-
- - setGaugeColor: (NXColor)color
- {
- if (NXEqualColor (color, [self gaugeColor]) == NO)
- {
- [ [self cell] setGaugeColor: color];
- [self update];
- }
- return self;
- }
-
-
- - setTextColor: (NXColor)color
- {
- if (NXEqualColor (color, [self textColor]) == NO)
- {
- [ [self cell] setTextColor: color];
- [self update];
- }
- return self;
- }
-
-
- //- (float)backgroundGray { return [ [self cell] backgroundGray]; }
- - (float)gaugeGray { return [ [self cell] gaugeGray]; }
- - (float)textGray { return [ [self cell] textGray]; }
-
- /*
- - setBackgroundGray: (float)gray
- {
- if (gray != [self backgroundGray])
- {
- [ [self cell] setBackgroundGray: gray];
- [self update];
- }
- return self;
- }
- */
-
- - setGaugeGray: (float)gray
- {
- if (gray != [self gaugeGray])
- {
- [ [self cell] setGaugeGray: gray];
- [self update];
- }
- return self;
- }
-
-
- - setTextGray: (float)gray
- {
- if (gray != [self textGray])
- {
- [ [self cell] setTextGray: gray];
- [self update];
- }
- return self;
- }
-
-
- - titleFont { return [ [self cell] titleFont]; }
- - (const char *)title { return [ [self cell] title]; }
- - (int)titlePosition { return [ [self cell] titlePosition]; }
-
-
- - setTitleFont: newFont
- {
- [ [self cell] setTitleFont: newFont];
- [self update];
- return self;
- }
-
-
- - setTitle: (const char *)newTitle
- {
- [ [self cell] setTitle: newTitle];
- [self update];
- return self;
- }
-
-
- - setTitlePosition: (int)newPos
- {
- // Valid positions are NX_ATTOP and NX_ATBOTTOM.
- if (newPos != [self titlePosition])
- {
- [ [self cell] setTitlePosition: newPos];
- [self update];
- }
- return self;
- }
-
- @end
-
-